package cn.edu.ujs.coor.response;

import cn.edu.ujs.coor.request.PageRequest;
import lombok.Data;

import java.util.List;

@Data
public class PageResponse<T> {

    private int size;

    private int page;

    private long total;

    private List<T> dataList;

    public int getPage() {
        return page < 1 ? 1 : page;
    }

    public int getSize() {
        return size <= 0 ? 10 : size;
    }

    public PageResponse(List<T> dataList, PageRequest request, long total) {
        this.size = request.getPageSize();
        this.page = request.getPage();
        this.total = total;
        this.dataList = dataList;
    }

    public PageResponse() {
    }
}